#include <types.h>
#include <sys_config.h>

#include <retcode.h>
#include <api/libc/string.h>
#include <api/libc/printf.h>
#include <osal/osal.h>
#include <hld/hld_dev.h>
#include <hld/dis/vpo.h>
#include <hld/decv/vdec_driver.h>
#include <hld/decv/decv.h>
#include <hld/ge/ge.h>
#include <hld/osd/osddrv.h>

#include <api/libimagedec/imagedec.h>
#include <api/libmp/png.h>
#include <api/libmp/pe.h>
#include "../../image_engine.h"
#include "../../plugin.h"
#include <api/libfs2/stdio.h>

//#define AD_PNG_DEBUG

#ifdef AD_PNG_DEBUG
#define AD_PNG_PRINTF	libc_printf
#else
#define AD_PNG_PRINTF(...)	do{}while(0)
#endif

#define ENABLE_PE_CACHE
#ifdef 	ENABLE_PE_CACHE
#define	PNG_BLOCK_SIZE		(320 * 1024)
#define PNG_CACHE_SIZE		(PNG_BLOCK_SIZE * 2)
#define PNG_BIT_SIZE		(64*1024)
#define PNG_DEC_SIZE		0x8e900
static int png_cache_id = -1;
static UINT8 *png_cache_buffer;
#endif

//extern int gif_cache_id;
//BOOL jpeg_decoder_task_not_over;        // added for bug fixing : avoid running of two decoder task at one time.
struct jpeg_file
{
	imagedec_id				id; 			//image id for decoder			
	Imagedec_Init_Config 	init_conf;		//configurefor decoder
	
	FILE					*fp;			//file pointer for JPEG
	unsigned long			task_terminated;	
	mp_callback_func		mp_cb;			//callback function for mp
	OSAL_ID					lock;
};

static struct jpeg_file jpeg_file;
static struct png_cfg png_cfg;
static struct image_display_t dpy;

static struct png_instance *png = NULL;

static int png_read_data(UINT32 fh,BYTE *buf, UINT32 size)
{
	int ret = 0;
#ifdef ENABLE_PE_CACHE
	if(png_cache_id >= 0)
	{
		ret = pe_cache_read(png_cache_id, buf, size, 0xFFFFFFFF);
		return ret;
	}
#endif	

#ifndef ENABLE_PE_CACHE
	FILE *fp =  (FILE*)fh;
	int byte_read;
	
	if(fp == NULL)
	{
		return -1;
	}

	byte_read = fread(buf, size, 1, fp);

	return ((byte_read < 0) ? 0 : byte_read) ;
#endif
	
}

static int png_seek_data(UINT32 fh,long offset, UINT32 origin)
{
#ifdef ENABLE_PE_CACHE
    if(png_cache_id >= 0)
    {
        pe_cache_seek(png_cache_id, (off_t)offset, origin);
        return 0;
    }
#endif

#ifndef ENABLE_PE_CACHE
	FILE *fp = (FILE*)fh;

	if(fp == NULL)
	{
		return -1;
	}

	fseek(fp, (off_t)offset, origin);
#endif
	return 0;
}

static int png_tell_pos(UINT32 fh)
{
 	return 0;
}

static UINT32 jpeg_process(void *value)
{
	unsigned long process = *(unsigned long*)value;
	unsigned long err = process >> 24;
	
	process = (process * 100) >> 16;

	if(process > 100) process = 100;
	
	osal_mutex_lock(jpeg_file.lock, TMO_FEVR);
	if(jpeg_file.mp_cb)
	{
		if(err == 0)
			jpeg_file.mp_cb(MP_IMAGE_DECODE_PROCESS, process);
		else
			jpeg_file.mp_cb(MP_IMAGE_DECODER_ERROR, err);
	}
	osal_mutex_unlock(jpeg_file.lock);

	return 0;
}

static void pic_png_init(void)
{
	//struct png_cfg cfg;	
	png = png_open(&png_cfg);    
}

static int png_initial(struct pe_image_cfg *pe_image_cfg)
{

#ifdef ENABLE_PE_CACHE	
	png_cache_buffer = (unsigned char *)(((unsigned long)pe_image_cfg->decoder_buf) & 0xfffffff0);
	png_cache_buffer = (unsigned char *)(((unsigned long)png_cache_buffer & 0x0fffffff) | 0x80000000);
	
#endif
    MEMSET((void *)&png_cfg,0,sizeof(struct png_cfg));
	png_cfg.bit_buf_start = pe_image_cfg->decoder_buf +PNG_CACHE_SIZE;
	png_cfg.bit_buf_size = PNG_BIT_SIZE;
	png_cfg.dec_buf_start = png_cfg.bit_buf_start + PNG_BIT_SIZE;
	png_cfg.dec_buf_size = pe_image_cfg->decoder_buf_len - PNG_CACHE_SIZE - PNG_BIT_SIZE;
    png_cfg.dec_buf = png_cfg.dec_buf_start;
    png_cfg.dec_buf_totalsize = png_cfg.dec_buf_size;
    if(ALI_S3821== sys_ic_get_chip_id())
        image_png_init();
	
}
	
static int png_is_our_file(char *filename)
{
	char *ext;
#ifndef	 _USE_32M_MEM_	
	ext = strrchr(filename, '.');
	if (ext)
	{
		if((!strncasecmp(ext, ".png", 4)))
		{
			return IMAGE_IS_OUR_FILE;
		}
	}
#endif
	return IMAGE_NOT_OUR_FILE;
}

enum Output_Frame_Ret_Code imagedec_mp_request(void *dev, void *pinfo);
BOOL imagedec_mp_release(void *dev,UINT8 utop_idx,UINT8 frm_array_idx);

enum Output_Frame_Ret_Code imagedec_mp_request_ext(void *dev,struct Display_Info *pinfo,struct Request_Info *pRequest_Info);
RET_CODE imagedec_mp_release_ext(void *pdev,struct Release_Info *pRelease_Info);//UINT8 utop_idx,UINT8 frm_array_idx)

#ifdef  DUAL_ENABLE
#define OSD_SCREEN_WIDTH 1280
static const osd_scale_param m_osd_scale_map_576[] =
{
    {PAL, 1,1,1,1/*{UI_SCREEN_WIDTH, UI_SCREEN_HEIGHT, 720, 576}*/},
    {PAL_N, 1,1,1,1/*{UI_SCREEN_WIDTH, UI_SCREEN_HEIGHT, 720, 576}*/},
    {PAL_NC, 1,1,1,1/*{UI_SCREEN_WIDTH, UI_SCREEN_HEIGHT, 720, 576}*/},

    {NTSC, 1,6,1,5/*{UI_SCREEN_WIDTH, UI_SCREEN_HEIGHT, 720, 480}*/},
    {NTSC_443, 1,6,1,5/*{UI_SCREEN_WIDTH, UI_SCREEN_HEIGHT, 720, 480}*/},
    {PAL_60, 1,6,1,5/*{UI_SCREEN_WIDTH, UI_SCREEN_HEIGHT, 720, 480}*/},
    {PAL_M, 1,6,1,5/*{UI_SCREEN_WIDTH, UI_SCREEN_HEIGHT, 720, 480}*/},

    {LINE_720_25, 9, 4, 16, 5/*{UI_SCREEN_WIDTH, UI_SCREEN_HEIGHT, 1280, 720 }*/},
    {LINE_720_30, 9, 4, 16, 5/*{UI_SCREEN_WIDTH, UI_SCREEN_HEIGHT, 1280, 720}*/},

    {LINE_1080_25, 3,8,8,15/*{UI_SCREEN_WIDTH, UI_SCREEN_HEIGHT, 1920, 1080}*/},
    {LINE_1080_30, 3,8,8,15/*{UI_SCREEN_WIDTH, UI_SCREEN_HEIGHT, 1920, 1080}*/},
};

static const osd_scale_param m_osd_scale_map_720[] =
{
    {PAL, 16,5,9,4,/*{UI_SCREEN_WIDTH, UI_SCREEN_HEIGHT, 720, 576}*/},
    {PAL_N, 16,5,9,4,/*{UI_SCREEN_WIDTH, UI_SCREEN_HEIGHT, 720, 576}*/},
    {PAL_NC, 16,5,9,4,/*{UI_SCREEN_WIDTH, UI_SCREEN_HEIGHT, 720, 576}*/},

    {NTSC, 16,3,9,2,/*{UI_SCREEN_WIDTH, UI_SCREEN_HEIGHT, 720, 480}*/},
    {NTSC_443, 16,3,9,2,/*{UI_SCREEN_WIDTH, UI_SCREEN_HEIGHT, 720, 480}*/},
    {PAL_60, 16,3,9,2,/*{UI_SCREEN_WIDTH, UI_SCREEN_HEIGHT, 720, 480}*/},
    {PAL_M, 16,3,9,2,/*{UI_SCREEN_WIDTH, UI_SCREEN_HEIGHT, 720, 480}*/},

    {LINE_720_25, 1, 1, 1, 1},
    {LINE_720_30, 1, 1, 1, 1},

    {LINE_1080_25, 2,2,3,3,/*{UI_SCREEN_WIDTH, UI_SCREEN_HEIGHT, 1920, 1080}*/},
    {LINE_1080_30, 2,2,3,3,/*{UI_SCREEN_WIDTH, UI_SCREEN_HEIGHT, 1920, 1080}*/},
};

static const osd_scale_param m_osd_scale_map_1080[] =
{
    {PAL, 8*2,15,3*2,8,/*{UI_SCREEN_WIDTH, UI_SCREEN_HEIGHT, 720, 576}*/},
    {PAL_N, 8*2,15,3*2,8,/*{UI_SCREEN_WIDTH, UI_SCREEN_HEIGHT, 720, 576}*/},
    {PAL_NC, 8*2,15,3*2,8,/*{UI_SCREEN_WIDTH, UI_SCREEN_HEIGHT, 720, 576}*/},

    {NTSC, 8*2,9,3*2,4,/*{UI_SCREEN_WIDTH, UI_SCREEN_HEIGHT, 720, 480}*/},
    {NTSC_443, 8*2,9,3*2,4,/*{UI_SCREEN_WIDTH, UI_SCREEN_HEIGHT, 720, 480}*/},
    {PAL_60, 8*2,9,3*2,4,/*{UI_SCREEN_WIDTH, UI_SCREEN_HEIGHT, 720, 480}*/},
    {PAL_M, 8*2,9,3*2,4,/*{UI_SCREEN_WIDTH, UI_SCREEN_HEIGHT, 720, 480}*/},

    {LINE_720_25, 3, 3, 2, 2,/*{UI_SCREEN_WIDTH, UI_SCREEN_HEIGHT, 1280, 720 }*/},
    {LINE_720_30, 3, 3, 2, 2,/*{UI_SCREEN_WIDTH, UI_SCREEN_HEIGHT, 1280, 720}*/},

    {LINE_1080_25, 1,1,1,1,/*{UI_SCREEN_WIDTH, UI_SCREEN_HEIGHT, 1920, 1080}*/},
    {LINE_1080_30, 1,1,1,1,/*{UI_SCREEN_WIDTH, UI_SCREEN_HEIGHT, 1920, 1080}*/},
};

static UINT32 get_osd_scale_para(enum TVSystem eTVMode, INT32 nScreenWidth)
{
    UINT32 i,size_576,size_720,size_1080,size;
    const osd_scale_param  *p_ui_map;

    if (eTVMode == LINE_1080_24 || eTVMode == LINE_1152_ASS || eTVMode == LINE_1080_ASS || eTVMode == LINE_1080_50)
        eTVMode = LINE_1080_25;
    else if (eTVMode == LINE_1080_60)
        eTVMode = LINE_1080_30;

    size_720  = ARRAY_SIZE(m_osd_scale_map_720);
    size_1080 = ARRAY_SIZE(m_osd_scale_map_1080);
    size_576 = ARRAY_SIZE(m_osd_scale_map_576);
    if(nScreenWidth == 1280)
    {
        size = size_720;
        p_ui_map = m_osd_scale_map_720;
    }
    else if(nScreenWidth == 1920)
    {
        size = size_1080;
        p_ui_map = m_osd_scale_map_1080;
    }
    else // if(nScreenWidth == 720)
    {
        //ASSERT(0);
        size = size_576;
        p_ui_map = m_osd_scale_map_576;
    }
    for (i = 0; i < size; i++)
    {
        if (p_ui_map[i].tv_sys == eTVMode)
        {
            return &(p_ui_map[i]);
        }
    }
    // default to PAL
    return &(p_ui_map[0]);
}

static int osd_output_init(HANDLE hDev,UINT8 region_id, struct OSDRect *pRect, struct OSDPara *param)
{
    //UINT32 region_id =0;
    UINT32 trans_color;
    struct OSDRect region_rect;
    struct OSDPara OpenPara;
    enum TVSystem tvsys = PAL;

    region_rect.uLeft = pRect->uLeft;
	region_rect.uTop = pRect->uTop;
	region_rect.uWidth = pRect->uWidth;
	region_rect.uHeight = pRect->uHeight;

    OpenPara.eMode = param->eMode;
    OpenPara.uGAlpha = param->uGAlpha;
    OpenPara.uGAlphaEnable = param->uGAlphaEnable;
    OpenPara.uPalletteSel = param->uPalletteSel;

    struct osd_device *osd = (struct osd_device *)hDev;
    vpo_ioctl((struct vpo_device *)dev_get_by_id(HLD_DEV_TYPE_DIS, 0), VPO_IO_GET_OUT_MODE, (UINT32)(&tvsys));
    OSDDrv_Open((HANDLE)osd, &OpenPara);
    osal_task_sleep(20);
	OSDDrv_IoCtl((HANDLE)osd, OSD_IO_SET_TRANS_COLOR, 0x00);
	OSDDrv_CreateRegion((HANDLE)osd, region_id, &region_rect, NULL);
    region_rect.uLeft = region_rect.uTop = 0;
    OSDDrv_RegionFill((HANDLE)osd,region_id,&region_rect,0x00);
    UINT32 para = get_osd_scale_para(tvsys, OSD_SCREEN_WIDTH);
    OSDDrv_Scale((HANDLE)osd, OSD_SCALE_WITH_PARAM, para);
    OSDDrv_ShowOnOff((HANDLE)osd, TRUE);

}
#endif

PNG_RET png_view_routine_ge(struct png_image *img, struct png_view_par *par)
{
	ge_rect_t dst_rect, src_rect;
	//ge_surface_desc_t *src_surf, *dst_surf;
	struct ge_device *ge_dev;
	INT32 ret;
    ge_operating_entity entity;
    UINT32 layer_id = 0;
    UINT32 region_id =0;
    UINT32 cmd_hdl = 0;

#ifdef  DUAL_ENABLE
    struct osd_device *osd_dev;
    struct osd_device *osd;
   	struct OSDRect region_rect;
   	struct OSDRect rect;
   	struct OSDRect regionrect;
    struct OSDRect pRect;
   	struct OSDPara OpenPara;
	VSCR source;

    MEMSET((void *)&source,0,sizeof(VSCR));

    source.vR.uLeft = par->pos.x;
	source.vR.uTop = par->pos.y;
    source.lpbScr = (UINT8 *)img->graphic_buf;
    rect.uLeft = par->pos.x;
	rect.uTop = par->pos.y;

    if(ALI_S3821 == sys_ic_get_chip_id())
    {
        source.vR.uWidth = img->hw_stride;//img->size.w;
	    source.vR.uHeight = img->hw_y_stride;//img->size.h;
	    rect.uWidth =img->scale_w;//img->hw_stride;//img->size.w;
	    rect.uHeight = img->scale_h;// img->hw_y_stride;//img->size.h;
    }
    else
    {
        source.vR.uWidth = img->size.w;
	    source.vR.uHeight = img->size.h;
        rect.uWidth =source.vR.uWidth;//img->hw_stride;//img->size.w;
	    rect.uHeight = source.vR.uHeight;// img->hw_y_stride;//img->size.h;
    }

   	osd = (struct osd_device *)dev_get_by_id(HLD_DEV_TYPE_OSD, 0);
    if (osd == NULL)
	{
		AD_PNG_PRINTF("%s() osd device find failed!\n", __FUNCTION__);
		return -1;
	}

    osd_dev = (struct osd_device *)dev_get_by_id(HLD_DEV_TYPE_OSD, 0);
    if (osd_dev == NULL)
	{
		AD_PNG_PRINTF("%s() osd device find failed!\n", __FUNCTION__);
		return -1;
	}
    else
    {
        OSDDrv_Close((HANDLE)osd_dev);
        AD_PNG_PRINTF("%s() OSD_layer2 is closed!\n", __FUNCTION__);
    }

    pRect.uLeft = 136;
	pRect.uTop = 40;

    OpenPara.eMode = OSD_HD_ARGB8888;
    OpenPara.uGAlpha = 0x7f;
    OpenPara.uGAlphaEnable = 0;
    OpenPara.uPalletteSel = 0;


    if(ALI_S3602F == sys_ic_get_chip_id())
    {
        pRect.uWidth = 300;
	    pRect.uHeight = 300;
	    osd_dev = (struct osd_device *)dev_get_by_id(HLD_DEV_TYPE_OSD, 0);
    }
    else if(ALI_S3821 == sys_ic_get_chip_id())
    {
        pRect.uWidth = 1008;//640;
	    pRect.uHeight = 640;//360;
	    osd_dev = (struct osd_device *)dev_get_by_id(HLD_DEV_TYPE_OSD, 1);
    }
    else
    {
        pRect.uWidth = 640;
	    pRect.uHeight = 360;
	    osd_dev = (struct osd_device *)dev_get_by_id(HLD_DEV_TYPE_OSD, 1);
    }

    osd_output_init((HANDLE)osd_dev, region_id, &pRect, &OpenPara);
	ret = OSDDrv_RegionWrite((HANDLE)osd_dev,region_id,&source,&rect);

	return ret;

#endif

#ifndef  DUAL_ENABLE
	ge_dev = (struct ge_device *)dev_get_by_id(HLD_DEV_TYPE_GE, 0);
    ge_cmd_list_hdl cmd_list = ge_cmd_list_create(ge_dev, 1);
	if (ge_dev == NULL)
	{
		AD_PNG_PRINTF("%s() ge device find failed!\n", __FUNCTION__);
		return -1;
	}

	src_rect.left = 0;
	src_rect.top = 0;
    if(ALI_S3821 == sys_ic_get_chip_id())
    {
        src_rect.width = img->scale_w;//img->hw_stride;//img->hw_stride;
	    src_rect.height = img->scale_h;//img->hw_y_stride;//img->hw_y_stride;
	    entity.pixel_pitch = img->hw_stride;//src_rect.width;
    }
    else
    {
        src_rect.width = img->size.w;//img->hw_stride;//img->hw_stride;
	    src_rect.height = img->size.h;//img->hw_y_stride;//img->hw_y_stride;
	    entity.pixel_pitch = src_rect.width;//src_rect.width;
    }


	dst_rect.left = par->pos.x;
	dst_rect.top = par->pos.y;
	dst_rect.width = src_rect.width;
	dst_rect.height = src_rect.height;

    ge_cmd_list_new(ge_dev,cmd_list,GE_COMPILE_AND_EXECUTE);
    ge_gma_set_region_to_cmd_list(ge_dev,layer_id,region_id,cmd_list);

    entity.color_format = GE_PF_ARGB8888;
	entity.base_address = (UINT8 *)img->graphic_buf;
	entity.data_decoder = GE_DECODER_DISABLE;

    entity.modify_flags = GE_BA_FLAG_ADDR|GE_BA_FLAG_FORMAT|GE_BA_FLAG_PITCH;

    cmd_hdl = ge_cmd_begin(ge_dev,cmd_list,GE_DRAW_BITMAP);
	ge_set_operating_entity(ge_dev,cmd_hdl,GE_PTN,&entity);
	ge_set_clut_rgb_order(ge_dev,cmd_hdl,GE_RGB_ORDER_ARGB);
	ge_set_xy(ge_dev,cmd_hdl,GE_DST,dst_rect.left,dst_rect.top);
	ge_set_xy(ge_dev,cmd_hdl,GE_SRC,dst_rect.left,dst_rect.top);
	ge_set_xy(ge_dev,cmd_hdl,GE_PTN,src_rect.left,src_rect.top);
	ge_set_wh(ge_dev,cmd_hdl,GE_DST_PTN,dst_rect.width,dst_rect.height);
	ge_cmd_end(ge_dev,cmd_hdl);

	return ret;
#endif
}


static void pic_png_dec(png_file fh, struct OSDRect *rect)
{
	struct png_file file;
	MEMSET((void *)&file, 0, sizeof(struct png_file));
	file.handle = fh;
	file.fread = png_read_data;
	file.fseek = png_seek_data;
	file.ftell = png_tell_pos;

	struct png_image img;
	MEMSET((void *)&img, 0, sizeof(struct png_image));
#ifdef PNG_OUT_CLUT8_PIC
	img.cf_defined = PNG_CF_DEFINED_AUTOMATICALLY;
#else
	img.cf_defined = PNG_CF_DEFINED_MANUALLY; 
#endif
	img.plt_type = PNG_PLT_AYCBCR8888;

	png_dec(png, &file, &img, PNG_SYNC);  //the synchronous mode
    struct png_view_par view_par;
    MEMSET((void *)&view_par, 0, sizeof(struct png_view_par));
    view_par.handle0 = 0;
    view_par.pos.x = rect->uLeft;
    view_par.pos.y = rect->uTop;
    if(ALI_S3821 != sys_ic_get_chip_id())
    {
    	png_view(png, &img, &view_par, png_view_routine_ge);
    }
    else
        png_view_routine_ge(&img, &view_par);
}

static int png_decode(char *filename, void *args)
{
	png_file fh;
	struct OSDRect rect;
	char *ext;
	
	ext = strrchr(filename, '.');
	if (ext)
	{
		if((strncasecmp(ext, ".png", 4)) )
		{            
			return IMAGE_DEC_E_FAIL;
		}
	}

#ifndef ENABLE_PE_CACHE
	FILE *fp = fopen(filename, "rb");
	if(fp == NULL)
	{
		return IMAGE_DEC_E_OPEN_FAIL;
	}
	fh = (gif_file)fp;
#endif

/*
#ifdef ENABLE_PE_CACHE
	if(gif_cache_id >= 0) pe_cache_close(gif_cache_id);
	gif_cache_id = -1;
#endif
*/

#ifdef ENABLE_PE_CACHE
	AD_PNG_PRINTF("filename: %s\n", filename);
	png_cache_id = pe_cache_open(filename, png_cache_buffer, PNG_CACHE_SIZE, PNG_BLOCK_SIZE);
	AD_PNG_PRINTF("filename: %s,  pe_cache_id: %d\n", filename, png_cache_id);
	if (png_cache_id < 0)
		return IMAGE_DEC_E_OPEN_FAIL;
#endif

#ifdef ENABLE_PE_CACHE
	fh = 1;			// avoid imagedec_decode return FALSE without FS API
#endif

	rect.uLeft = 0;
	rect.uTop = 0;
	rect.uHeight = 600;
	rect.uWidth = 800;
	
	pic_png_init();
	pic_png_dec(fh, &rect);

/*
#ifdef ENABLE_PE_CACHE
	pe_cache_close(png_cache_id);
	png_cache_id = -1;
#endif

#ifndef ENABLE_PE_CACHE
	fclose(fp);
	fp = NULL;
#endif
*/
	
	
	return IMAGE_DEC_E_OK;	
}

static int png_abort(void)
{
    struct osd_device *osd_dev;
    struct OSDRect rect;
	/*
	if(jpeg_file.id > 0)
	{
		osal_mutex_lock(jpeg_file.lock, TMO_FEVR);
		jpeg_file.mp_cb = NULL;
		osal_mutex_unlock(jpeg_file.lock);

		imagedec_stop(jpeg_file.id);

		while(jpeg_file.task_terminated == 1)
		{
			osal_task_sleep(10);
		}
	}
	*/
#ifdef ENABLE_PE_CACHE
	if(png_cache_id >= 0) pe_cache_close(png_cache_id);
	png_cache_id = -1;
#endif

	if (png == NULL)
		return;
/*	png_stop(png);
*/	png_close(png);
#ifndef  DUAL_ENABLE
    osd_dev = (struct osd_device *)dev_get_by_id(HLD_DEV_TYPE_OSD, 0);
    OSDDrv_GetRegionPos((HANDLE)osd_dev,0,&rect);
    rect.uLeft = rect.uTop = 0;
    OSDDrv_RegionFill((HANDLE)osd_dev,0,&rect,0x00);
#endif
    //OSD_ClearScreen();
#ifdef  DUAL_ENABLE
    if(ALI_S3602F == sys_ic_get_chip_id())
    {
        osd_dev = (struct osd_device *)dev_get_by_id(HLD_DEV_TYPE_OSD, 0); 
        OSDDrv_ShowOnOff((HANDLE)osd_dev,FALSE);
        OSDDrv_Close((HANDLE)osd_dev);
    }
    else
    {
        osd_dev = (struct osd_device *)dev_get_by_id(HLD_DEV_TYPE_OSD, 1); 
        OSDDrv_ShowOnOff((HANDLE)osd_dev,FALSE);
        OSDDrv_Close((HANDLE)osd_dev);
    }
      
   
#endif
	png = NULL;
	
}


ImagePlugin png_plugin =
{
	.handle = 0,
	.filename = NULL,
	.description = NULL,
	.init = png_initial,
	.about = NULL,
	.configure = NULL,
	.is_our_file = png_is_our_file,
	.decode = png_decode,
	.show = NULL,
	.abort = png_abort,
	.cleanup = NULL,
	.get_info = NULL,
	.rotate = NULL,
	.zoom = NULL,
};

